﻿#pragma once

#include <windows.h>

#undef min
#undef max

// 注意 windows 一定要放在 gdiplus 前面
#include <gdiplus.h>

#include <learn/painter/paint_ctx.h>

namespace xi
{

namespace painter
{

class EXT_SYMBOL Win_Context
{
  public:
    /**
     * @brief 创建 Windows 窗口
     *
     * @param[in] hInstance
     * @param[in] nCmdShow
     * @param[in] x
     * @param[in] y
     * @param[in] width
     * @param[in] height
     * @param[in] init
     * @param[in] deal
     * @param[in] title
     */
    Win_Context(HINSTANCE hInstance, int nCmdShow, int x, int y, int width, int height,
               std::function<void(const Paint_Context *)> init,
               std::function<void(const Paint_Context *)> deal, const wchar_t *title);

    /**
     * @brief 消息循环
     *
     * @return int
     */
    int message_loop();

  protected:
    HWND m_hWnd;              // 窗口句柄
    ULONG_PTR m_gdiplusToken; // gdi token
};

} // namespace painter

} // namespace xi
